package server;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class PassVerifier {

	private PrintWriter pw;
	private BufferedReader br;
	private long challenge;

	public PassVerifier(PrintWriter pw, BufferedReader br) {
		this.pw = pw;
		this.br = br;
	}

	

	public void sendChallenge() {
		long challenge = System.currentTimeMillis();
		this.challenge = challenge;
		pw.println(challenge);
		pw.flush();
	}

	public boolean waitNAct() {
		String response;
		try {
			response = br.readLine();
			if(response == null){
				return false;
			}
			if (response.equals(challenge + "pd")) {
				return true;
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
		return false;
	}

}
